#include <iostream>
#include <unistd.h>
#include <signal.h>
int Acnt = 0;
void func(int sig)
{
    std::cout << "child cnt->" << Acnt << std::endl;
    exit(errno);
}
int main()
{
    pid_t id = fork();
    if (id == 0)
    {
        // child: no io plus
        signal(SIGALRM, func);
        alarm(1);
        while (true)
        {
            Acnt++;
        }
    }
    // father: io plus
    int cnt = 0;
    alarm(1);
    while (true)
    {
        std::cout << "father cnt->" << cnt << std::endl;
        cnt++;
    }
    return 0;
}